package com.yindi.sftp.utils;

import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

import java.io.InputStream;

@Slf4j
public class Dom4jUtil {

    public static Document read(InputStream is) throws DocumentException {
        try {
            // 创建SAXReader实例
            SAXReader reader = new SAXReader();
            // read()读取指定的XML文档并形成DOM树
            return reader.read(is);
        } catch (DocumentException e){
            log.error("读取配置失败: {}", e.getMessage());
        }
        return null;
    }
}
